package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class WmchannelController {

    @Autowired
    private WmChannelService wmChannelService;
    @GetMapping("/channels")
    public ResponseResult findAll(){
        return wmChannelService.channeList();
    }

    //新建频道
    @PostMapping("/save")
    public ResponseResult channelSave(@RequestBody WmChannel wmChannel){
        return wmChannelService.channelSave(wmChannel);

    }
    //查询频道列表
    @PostMapping("/list")
    public  ResponseResult channelFind(@RequestBody ChannelDto dto){
        return wmChannelService.channelFind(dto);
    }

    //修改信息，修改状态
    @PostMapping("/update")
    public  ResponseResult update(@RequestBody WmChannel wmChannel){
     return wmChannelService.update(wmChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult del(@PathVariable ("id") Integer id){
        return  wmChannelService.del(id);
    }
}